﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using CinemaDbLib;
using ModelLayer;

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "TicketCtrl" in code, svc and config file together.
public class TicketCtrl : ITicketCtrl
{
	private TicketDB ticketDB;

	public TicketCtrl()
	{
		ticketDB = new TicketDB();
	}

	public int addTicket(int scheduleId, int seatId)
	{
		Ticket ticket = new Ticket(-1, new Schedule(scheduleId), new Seat(seatId));
		return ticketDB.insertTicket(ticket);
	}

	public bool removeTicket(int id)
	{
		return ticketDB.removeTicket(id);
	}

	public bool updateTicket(int id, Schedule schedule, Seat seat)
	{
		Ticket ticket = new Ticket(id, schedule, seat);
		return ticketDB.updateTicket(ticket);
	}

	public Ticket getTicketById(int id)
	{
		return ticketDB.getTicketById(id);
	}

	public Ticket[] getTickets()
	{
		return ticketDB.getTickets().ToArray();
	}

	public Ticket[] getTicketsBySchedule(int scheduleId)
	{
		return ticketDB.getTicketsBySchedule(scheduleId).ToArray();
	}
}
